//-----------------Sonic CD Fire Gun Script-------------------//
// Yeah...

// Aliases
#alias Object.Value0	:	Object.Timer
#alias Object.Value1	:	Object.Delay
#alias Object[24].PropertyValue	:	HUD.CurrentTimePeriod

// ========================
// Subs
// ========================

sub ObjectMain
	Object.DrawOrder =  4
	Object.Delay = Object.PropertyValue
	Object.Delay <<= 4
	Object.Timer++
	if Object.Timer == Object.Delay
		Object.Timer = 0
			PlayStageSFX(6, false)
			TempValue1  = Object.XPos
			TempValue1 -= 0x00000

			TempValue2  = Object.YPos
			TempValue2 -= 0x100000
			CreateTempObject(TypeName[FireBall], TempValue0, TempValue1, TempValue2)
			Object[TempObjectPos].DrawOrder =  3
			Object[TempObjectPos].PropertyValue =  0
			TempValue0++
	end if
end sub

sub ObjectDraw
	DrawSprite(0)
end sub

sub ObjectStartup
	LoadSpriteSheet("R2/Objects2.gif")

	TempValue0 = HUD.CurrentTimePeriod
	TempValue1 = 1
	TempValue0 *= 33
	TempValue1 += TempValue0 
	SpriteFrame(-16, -4, 32, 9, TempValue1, 99)
	ArrayPos0 = 32
	while ArrayPos0 < 1056
		if Object[ArrayPos0].Type == TypeName[FireGun]
			Object[ArrayPos0].DrawOrder = 4
		end if
		ArrayPos0++
	loop
end sub

// ========================
// Editor Subs
// ========================

sub RSDKEdit
	if editor.returnVariable == true
		switch editor.variableID
		case EDIT_VAR_PROPVAL // property value
		case 0 // property value
			checkResult = object.propertyValue
			break
		end switch
	else
		switch editor.variableID
		case EDIT_VAR_PROPVAL // property value
		case 0 // property value
			object.propertyValue = editor.variableValue
			break
		end switch
	end if
end sub

#alias 0	:	INK_NONE
#alias 1	:	INK_BLEND

sub RSDKDraw
	DrawSprite(0)
	TempValue0 = 16; TempValue1 = 4; TempValue2 = 16; TempValue3 = 5;
	CallFunction(EditorHelpers_DrawHitbox)

	if editor.showGizmos == true
		editor.drawingOverlay = true

		TempValue0 = object.ypos
		TempValue0 += 0x40 0000

		DrawArrow(object.xpos, object.ypos, object.xpos, TempValue0, 255, 255, 255)

		object.inkEffect = 1
		DrawSpriteFX(1, FX_INK, object.xpos, TempValue0)
		object.inkEffect = 0

		editor.drawingOverlay = false
	end if
end sub


sub RSDKLoad
	LoadSpriteSheet("R2/Objects2.gif")
	SpriteFrame(-16, -4, 32, 9, 1, 99)		// #0 - BrickBlock
	SpriteFrame(-8, -17, 16, 33, 182, 134)  // #1 - I DON'T CARE HOW BIG THE ROOM IS, I CAST FIRE BALL!!

	SetVariableAlias(ALIAS_VAR_PROPVAL, "delay")
end sub